package controleur;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JButton;
import javax.swing.JOptionPane;

import vue.AffichageCreationCollection;
import vue.AffichageGlobal;
import vue.AffichageMenu;
/**
 * 
 * @author Plancq Charlotte, Lanvin Kévin, Darras Raphael
 *
 *
 */
public class CreationCollectionListener extends KeyAdapter implements ActionListener {
	AffichageGlobal p;
	AffichageCreationCollection c;

	public CreationCollectionListener(AffichageGlobal a,AffichageCreationCollection c) {
		this.c=c;
		this.p=a;
	}
	
	
	public void keyReleased (KeyEvent e){
		if(e.getKeyCode()==KeyEvent.VK_ENTER){
			p.getTraitement().creerCollection(c.getNom());
			JOptionPane.showMessageDialog(c, "La collection a bien ete creee !");
			p.setCentre(new AffichageMenu(p));
		}
	}
	
	public void actionPerformed(ActionEvent e) {
		JButton b = (JButton) e.getSource();
		if (b.getText().equals("Creer la collection !")) {
			p.getTraitement().creerCollection(c.getNom());
			JOptionPane.showMessageDialog(c, "La collection a bien ete creee !");
			p.setCentre(new AffichageMenu(p));
		}
	}

}
